package net.aetherial.context.grounding.gatherers;

import net.aetherial.context.grounding.gatherers.bots.*;

/**
 * Sends turns collected by an <code>IrcBot</code> to the rest of the system.
 */

public class IrcGatherer extends Gatherer 
{
	/**
	 * Starts the thread that initializes and starts the bot. In the current incarnation, it logs on to <code>#linux</code> on <code>irc.freenode.net</code>. 
	 */

	public void run() 
	{
		try 
		{
			IrcBot bot = new IrcBot ();

			bot.setGatherer (this);

			bot.setVerbose (false);
			bot.connect ("irc.freenode.net");
			bot.joinChannel ("#linux");
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
		}
	}

	/**
	 * Sends an incoming message to rest of the system.
	 *  
	 * @param sender		Handle of sender
	 * @param message		Turn contents
	 * @param score			Coded score (if available)
	 */
	
	public void process (String sender, String message, double score)
	{
		try
		{
			analyzer.process (sender, message, score);
		}
		catch (Exception e)
		{
			e.printStackTrace ();
		}
	}
}
